package com.ruoyi.system.service.impl;

import com.ruoyi.common.utils.DateUtils;
import com.ruoyi.system.domain.Project;
import com.ruoyi.system.mapper.AchievementMapper;
import com.ruoyi.system.service.IAchievementService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;


/**
 * 需求Service业务层处理
 *
 * @author EdwardXRX
 * @date 2024-04-12
 */
@Service
public class AchievementServiceImpl implements IAchievementService
{
    @Autowired
    private AchievementMapper achievementMapper;

    /**
     * 查询需求
     *
     * @param id 需求主键
     * @return 需求
     */
    @Override
    public Project selectProjectById(Long id)
    {
        Project project = achievementMapper.selectProjectById(id);
        project.setClickNum(project.getClickNum() + 1);
        achievementMapper.updateProject(project);
        return project;
    }

    /**
     * 查询需求列表
     *
     * @param project 需求
     * @return 需求
     */
    @Override
    public List<Project> selectProjectList(Project project)
    {
        return achievementMapper.selectProjectList(project);
    }

    /**
     * 新增需求
     *
     * @param project 需求
     * @return 结果
     */
    @Override
    public int insertProject(Project project)
    {
        project.setCreateTime(DateUtils.getNowDate());
        return achievementMapper.insertProject(project);
    }

    /**
     * 修改需求
     *
     * @param project 需求
     * @return 结果
     */
    @Override
    public int updateProject(Project project)
    {
        return achievementMapper.updateProject(project);
    }

    /**
     * 批量删除需求
     *
     * @param ids 需要删除的需求主键
     * @return 结果
     */
    @Override
    public int deleteProjectByIds(Long[] ids)
    {
        return achievementMapper.deleteProjectByIds(ids);
    }

    /**
     * 删除需求信息
     *
     * @param id 需求主键
     * @return 结果
     */
    @Override
    public int deleteProjectById(Long id)
    {
        return achievementMapper.deleteProjectById(id);
    }

    @Override
    public List<Project> selectProjectListByUserId(Long userId) {
        return achievementMapper.selectProjectListByUserId(userId);
    }

    @Override
    public List<Project> listAchievementByClickNum() {
        return achievementMapper.listAchievementByClickNum();
    }
}
